/**
 *    Copyright (C) 2008, 2009  Victor Smirnov <aist11@gmail.com>
 *
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License along
 *    with this program; if not, write to the Free Software Foundation, Inc.,
 *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 *    See LICENSE.exceptions in the root folder of this project for possible
 *    exceptions
 *
 */

#ifndef _CUBEFS_API_METADATA_FIELD_HPP
#define _CUBEFS_API_METADATA_FIELD_HPP

#include <cubefs/api/metadata/metadata.hpp>

namespace cubefs    {
namespace api       {

struct CUBEFS_API FieldMetadata: public Metadata {

    typedef TypeList<Pair<TypeCode<BYTE>,    Byte>,
            TypeList<Pair<TypeCode<UBYTE>,   UByte>,
            TypeList<Pair<TypeCode<SHORT>,   Short>,
            TypeList<Pair<TypeCode<USHORT>,  UShort>,
            TypeList<Pair<TypeCode<INT>,     Int>,
            TypeList<Pair<TypeCode<UINT>,    UInt>,
            TypeList<Pair<TypeCode<BIGINT>,  BigInt>,
            TypeList<Pair<TypeCode<ID>,      IDValue> > > > > > > > >       Code2TypeMap;

    virtual Int Ptr() const  												= 0;
    virtual Int AbiPtr() const  											= 0;
    virtual Int Count() const 												= 0;

    virtual Int Size() const 												= 0;
    virtual Int Offset() const  											= 0;
    virtual Int Limit() const 												= 0;

    virtual const void *ValuePtr(const void *mem, Int idx) const 			= 0;
    virtual void *ValuePtr(void *mem, Int idx) 								= 0;

    virtual const void *ValuePtrAbi(const void *mem, Int idx) const 		= 0;
    virtual void *ValuePtrAbi(void *mem, Int idx) 							= 0;


    virtual const void *BitmapPtr(const void *mem) const 					= 0;
    virtual void *BitmapPtr(void *mem) 										= 0;

    virtual const void *BitmapPtrAbi(const void *mem) const 				= 0;
    virtual void *BitmapPtrAbi(void *mem) 									= 0;

    virtual void GetValue(const void *mem, void *value, Int idx) const 		= 0;
    virtual void GetValueAbi(const void *mem, void *value, Int idx) const 	= 0;

    virtual void SetValue(void *mem, const void *value, Int idx) 			= 0;
    virtual void SetValueAbi(void *mem, const void *value, Int idx) 		= 0;

    virtual BigInt GetBits(const void *mem, Int idx, Int nbits) const 		= 0;
    virtual BigInt GetBitsAbi(const void *mem, Int idx, Int nbits) const 	= 0;

    virtual void SetBits(void *mem, BigInt bits, Int idx, Int nbits) 		= 0;
    virtual void SetBitsAbi(void *mem, BigInt bits, Int idx, Int nbits) 	= 0;

    virtual Typed* CreateValueHolder()										= 0;
    virtual Type* GetValueType() 											= 0;

    static Type* MyType();
};

CUBEFS_DECLARE_TYPENAME(FieldMetadata,    "cubefs::api::metadata::FieldMetadata");

}}

#endif
